package com.yonyou.ucf.mdf.app.isvdxq.secondpart.controller;

import com.yonyou.ucf.mdf.app.isvdxq.ReturnResult.DataResult;
import com.yonyou.ucf.mdf.app.isvdxq.common.DxqConfig;
import com.yonyou.ucf.mdf.app.isvdxq.other.service.BaseService;
import com.yonyou.ucf.mdf.app.isvdxq.secondpart.service.VideologService;
import com.yonyou.ucf.mdf.app.isvdxq.utils.RequestTool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping(value = {DxqConfig.pre_apiUrl+"/videolog",DxqConfig.pre_pcUrl+"/videolog"})
public class VideologController {
    private static final Logger logger = LoggerFactory.getLogger(VideologController.class);

    @Autowired
    BaseService baseService;

    @Autowired
    VideologService videologService;
    /**
     * /Videolog/UpdateFileData?appId=&appKey=Md5()
     * 批量上传 name,tenantId,orgId,creator,creatorName,type
     * @param request 测试
     * @return
     * @throws IOException
     */
    @RequestMapping("/UpdateFileData")
    public DataResult UpdateFileData(HttpServletRequest request) throws IOException {
        DataResult dataResult = new DataResult();
        //接收参数
        String tenantId = baseService.getTenantId(request);

        Map<String, Object> reqParams = RequestTool.getParams(request);
        String dataList = (String) reqParams.get("dataList");
        String appId = (String) reqParams.get("appId");
        String appKey = (String) reqParams.get("appKey");
        String appCode = (String) reqParams.get("appCode");
        //参数验证
//        String _appKey = DigestUtils.md5Hex(String.join(appId,"#",tenantId));
//        if(appKey != _appKey) return dataResult;

        boolean flag = videologService.AddEntitys(dataList);
        if(!flag) return dataResult;

        dataResult.setStatus(1);
        dataResult.setMessage("操作成功");
        return dataResult;
    }
}
